package xyz.xtt.asset.service.impl;

import static xyz.xtt.common.asset.AssertUtils.isFalse;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import xyz.xtt.asset.api.enums.AssetNoTypeEnum;
import xyz.xtt.asset.constants.ErrorMessage;
import xyz.xtt.asset.entity.AssetNoTransRecord;
import xyz.xtt.asset.mapper.AssetNoTransRecordMapper;
import xyz.xtt.asset.service.IAssetNoTransRecordService;

/**
 * <p>
 * 资产编号流转记录表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-03-18
 */
@Service
public class AssetNoTransRecordServiceImpl extends ServiceImpl<AssetNoTransRecordMapper, AssetNoTransRecord> implements IAssetNoTransRecordService {
	@Override
	public void setAssetNoTypeByAssetNo(String assetNo, Long appUserId) {
		isFalse(new LambdaUpdateChainWrapper<>(baseMapper)
				.eq(AssetNoTransRecord::getAssetNo, assetNo)
				.eq(AssetNoTransRecord::getAppUserId, appUserId)
				.set(AssetNoTransRecord::getAssetType, AssetNoTypeEnum.ASSET.getCode())
				.set(AssetNoTransRecord::getUpdateTime, System.currentTimeMillis())
				.update(), ErrorMessage.Asset_NO_TRANSRECORD_UPDATE_ERROR);
	}
}
